#ifndef __GLF_CORE_MACROS_H_INCLUDED__
#define __GLF_CORE_MACROS_H_INCLUDED__

#include <glf/config.h>

#define GLF_MAX(x, y)			((x) < (y) ? (y) : (x))
#define GLF_MAX3(x, y, z)		GLF_MAX(x, GLF_MAX(y, z))

#define GLF_MIN(x, y)			((x) < (y) ? (x) : (y))
#define GLF_MIN3(x, y, z)		GLF_MIN(x, GLF_MIN(y, z))

#define GLF_ROUNDUP(x, po2)		((x + (po2-1)) & ~(po2-1))
#define GLF_ROUNDDOWN(x, po2)	(x & ~(po2 - 1))

#define GLF_ROUNDUP4(x)			GLF_ROUNDUP(x, 4)
#define GLF_ROUNDUP32(x)		GLF_ROUNDUP(x, 32)

#define GLF_ROUNDDOWN4(x)		GLF_ROUNDDOWN(x, 4)
#define GLF_ROUNDDOWN32(x)		GLF_ROUNDDOWN(x, 32)

#define GLF_TOSTRING2(x)		#x
#define GLF_TOSTRING(x)			GLF_TOSTRING2(x)

#define GLF_TO_INT(x)			reinterpret_cast<int>(reinterpret_cast<const void*>(x))

#define GLF_OFFSETOF(s,m)		GLF_COMPILER_OFFSETOF(s,m)


#define GLF_IS_ALIGN4(x)		((GLF_TO_INT(x) &  3) == 0)
#define GLF_IS_ALIGN16(x)		((GLF_TO_INT(x) & 15) == 0)
#define GLF_IS_ALIGN32(x)		((GLF_TO_INT(x) & 31) == 0)

#define GLF_ASSERT_POINTER(p)	GLFi_ASSERT(p != 0)
#define GLF_ASSERT_ALIGN4(p)	GLFi_ASSERT(GLF_IS_ALIGN4(p))
#define GLF_ASSERT_ALIGN16(p)	GLFi_ASSERT(GLF_IS_ALIGN16(p))
#define GLF_ASSERT_ALIGN32(p)	GLFi_ASSERT(GLF_IS_ALIGN32(p))

#define GLF_DO_JOIN2(X, Y)		X##Y
#define GLF_DO_JOIN(X, Y)		GLF_DO_JOIN2(X, Y)
#define GLF_JOIN(X, Y)			GLF_DO_JOIN(X, Y)


template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];

// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef _MSC_VER
template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif

//singleton
#ifndef GLF_AS_DLL
	#define GLF_DECLARE_SINGLETON_PLACEMENT_NEW(name)	\
		static name* s_instance;						\
		static name* New##name(){						\
			return new (::malloc(sizeof(name))) name;	\
		}												\
		public:											\
		static name* GetInstance() {					\
			if(!s_instance) {							\
				s_instance = New##name();				\
			}											\
			return s_instance;							\
		}												\
		private:
	#define GLF_DEFINE_SINGLETON_PLACEMENT_NEW(name)	\
		name* name::s_instance = 0;						
	#define GLF_DECLARE_SINGLETON_WITH_DEP(name, dep)	\
		static name* s_instance;						\
		public:											\
		static name* GetInstance() {					\
			dep::GetInstance();							\
			if(!s_instance) {							\
				s_instance = new name();				\
			}											\
			return s_instance;							\
		}												\
		private:
	#define GLF_DEFINE_SINGLETON_WITH_DEP(name, dep)	\
		name* name::s_instance = 0;

#else //DLL version
	#define GLF_DECLARE_SINGLETON_PLACEMENT_NEW(name)	\
		static name* s_instance;						\
		static name* New##name();						\
		public:											\
		static name* GetInstance();						\
		private:
	#define GLF_DEFINE_SINGLETON_PLACEMENT_NEW(name)	\
		name* name::s_instance = 0;						\
		name* name::GetInstance() {						\
			if(!s_instance) {							\
				s_instance = New##name();				\
			}											\
			return s_instance;							\
		}												\
		name* name::New##name() {						\
			return new (::malloc(sizeof(name))) name;	\
		}
	#define GLF_DECLARE_SINGLETON_WITH_DEP(name, dep)	\
		static name* s_instance;						\
		public:											\
		static name* GetInstance();						\
		private:
	#define GLF_DEFINE_SINGLETON_WITH_DEP(name, dep)	\
		name* name::s_instance = 0;						\
		name* name::GetInstance() {						\
			dep::GetInstance();							\
			if(!s_instance) {							\
				s_instance = new name();				\
			}											\
			return s_instance;							\
		}
#endif

//array sizeof, get number of element in a static array
#define GLF_ARRAY_SIZE(x)		sizeof(ArraySizeHelper(x))
#define GLF_ASIZEOF(x)			GLF_ARRAY_SIZE(x)

#define GLF_MAKE4CC(a,b,c,d)	(((a&0xff)<<24)|((b&0xff)<<16)|((c&0xff)<<8)|((d&0xff)<<0))

#define GLF_SIZEOF_MEMBER(cls, member)		sizeof(static_cast<cls*>(0)->member)

#define GLF_ENUM_FLAG(name) \
	inline name operator|(name a, name b) { \
		return (name)((int)a | (int)b); \
	} \
	inline name operator&(name a, name b) { \
		return (name)((int)a & (int)b); \
	} \
	inline name operator~(name a) { \
		return (name)(~(int)a); \
	}\
	inline name& operator++(name& a) { \
		return (name&)++((int &)a); \
	}\
	inline name operator++(name a, int) { \
		return (name)((int)a++); \
	}\
	inline name operator<<(name a, int bitcount) { \
		return (name)((int)a << bitcount); \
	} \
	inline name& operator|=(name& a, name b) { \
		a = a | b; \
		return a; \
	} \
	inline name& operator&=(name& a, name b) { \
		a = a & b; \
		return a; \
	} \
	inline name& operator<<=(name& a, int bitcount) { \
		a = a << bitcount; \
		return a; \
	}

#undef GLF_NO_ALLOC_IMPL
#define GLF_NO_ALLOC_IMPL 0

#ifndef GLF_NO_ALLOC_IMPL
#define GLF_NO_ALLOC_IMPL 1
#endif

#if GLF_NO_ALLOC_IMPL

#define GLF_DECLARE_IMPL(size)	\
	public:						\
		struct Impl;			\
		friend struct Impl;		\
	private:					\
		char mImplBuffer[size];	\
		Impl& m;				\
	public:						\
		Impl& GetImpl() {		\
			return m;			\
		}

#else

#define GLF_DECLARE_IMPL(size)	\
	public:						\
		struct Impl;			\
		friend struct Impl;		\
	private:					\
		Impl& m;				\
	public:						\
		Impl& GetImpl() {		\
			return m;			\
		}

#endif

#include <glf/debug/console.h>

#define GLF_PRINT_ONCE(msg) \
	{ \
		static bool sCheck = false; \
		if(!sCheck) { \
			glf::Console::Println("%s(%d): %s - %s", __FILE__, __LINE__, __FUNCTION__, msg); \
			sCheck = true; \
		} \
	}

#define GLF_WARN_ONCE_IF(cond) if(cond) GLF_PRINT_ONCE(#cond)

#define GLF_UNIMPLEMENTED(comment) GLF_PRINT_ONCE(comment)

#if GLF_DEBUG
#	define GLF_DEBUG_ONLY(x) x
#else
#	define GLF_DEBUG_ONLY(x)
#endif

//! Evaluate expression
#define GLF_EVAL(...)                                           __VA_ARGS__

//! Convert arg to string
#define GLF_STRINGIFY(s)                                        #s
//! Evaluate arg before stringifying
#define GLF_STRINGIFY_EVAL(s)                                   GLF_STRINGIFY(s)

//! Append args together to form a new symbol
#define GLF_TOKENIZE(a, b)                                      a##b
//! Evaluate args before tokenizing
#define GLF_TOKENIZE_EVAL(a, b)                                 GLF_TOKENIZE(a, b)

//! Symbol evaluates to nothing
#define GLF_EMPTY
//! Function evaluates to nothing
#define GLF_EMPTYFUNC(...)

//! Remove brackets around parameter
#define GLF_UNBRACKET(...)                                      GLF_IFEQUAL(_UNBRACKET_TEST __VA_ARGS__, 1, GLF_EVAL __VA_ARGS__, __VA_ARGS__)

//! Get number of arguments in list.  Supports up to 10 args (limited because of high impact on compile time).
#define GLF_NUMARGS(...)                                        GLF_IF_EMPTY(0, _NUMARGS(__VA_ARGS__), __VA_ARGS__)

//! Use to avoid macro interpreting a comma as an argument delimiter
#define GLF_COMMA                                               ,

//! If Num is not CompareNum, then this will evaluate to a comma.  Useful for iteration over function parameters.
#define GLF_COMMA_IFNOT(Num, CompareNum)                        GLF_IFEQUAL(Num, CompareNum, GLF_EMPTY, GLF_COMMA)

//! Evaluate true or false depending on whether argument list is GLF_EMPTY
#define GLF_IF_EMPTY(True, False, ...)                           GLF_TOKENIZE_EVAL(_IF_EMPTY_CASE_, _GLF_IS_EMPTY(__VA_ARGS__))(True, False)

//! Evaluate True if Num == CompareNum, otherwise eval False.
#define GLF_IFEQUAL(Num, CompareNum, True, False)               GLF_IF_EMPTY(True, False, GLF_TOKENIZE_EVAL(_ITERATE_, Num##_##CompareNum))

//! Get number of elements in tuple
#define GLF_TUPLE_SIZE(t)                                       GLF_EVAL(NUMARGS t)
//! Get element in tuple. A tuple is a bracketed parameter list: (e0,e1,e2...).  Supports up to 5 elements.
#define GLF_TUPLE_ELEM(t, i)                                    GLF_TOKENIZE_EVAL(_TUPLE_ELEM_,TUPLE_SIZE(t))_ ## i t

//! Max number of iterations supported
#define GLF_ITERATE_MAX                                         20

//! Iterate calling Func(IterN, Args...) over range [Min, Max], where Min >= 0 and Max <= ITERATE_MAX.  IterN is the current iteration number.
#define GLF_ITERATE(Min, Max, Func)                             GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 0,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE1(Min, Max, Func, a1)                        GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 1,a1,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE2(Min, Max, Func, a1,a2)                     GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 2,a1,a2,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE3(Min, Max, Func, a1,a2,a3)                  GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 3,a1,a2,a3,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE4(Min, Max, Func, a1,a2,a3,a4)               GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 4,a1,a2,a3,a4,GLF_EMPTY)
#define GLF_ITERATE5(Min, Max, Func, a1,a2,a3,a4,a5)            GLF_TOKENIZE_EVAL(_ITERATE_, Min)(Max, Func, 5,a1,a2,a3,a4,a5)

//! Clone of ITERATE functions.  Macros don't support recursion, can't call ITERATE inside ITERATE.  Instead, change the inner recursive call to ITERATE_ or ITERATE__.
#define GLF_ITERATE_(Min, Max, Func)                            GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 0,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE1_(Min, Max, Func, a1)                       GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 1,a1,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE2_(Min, Max, Func, a1,a2)                    GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 2,a1,a2,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE3_(Min, Max, Func, a1,a2,a3)                 GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 3,a1,a2,a3,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE4_(Min, Max, Func, a1,a2,a3,a4)              GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 4,a1,a2,a3,a4,GLF_EMPTY)
#define GLF_ITERATE5_(Min, Max, Func, a1,a2,a3,a4,a5)           GLF_TOKENIZE_EVAL(_ITERATE__, Min)(Max, Func, 5,a1,a2,a3,a4,a5)

#define GLF_ITERATE__(Min, Max, Func)                           GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 0,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE1__(Min, Max, Func, a1)                      GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 1,a1,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE2__(Min, Max, Func, a1,a2)                   GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 2,a1,a2,GLF_EMPTY,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE3__(Min, Max, Func, a1,a2,a3)                GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 3,a1,a2,a3,GLF_EMPTY,GLF_EMPTY)
#define GLF_ITERATE4__(Min, Max, Func, a1,a2,a3,a4)             GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 4,a1,a2,a3,a4,GLF_EMPTY)
#define GLF_ITERATE5__(Min, Max, Func, a1,a2,a3,a4,a5)          GLF_TOKENIZE_EVAL(_ITERATE___, Min)(Max, Func, 5,a1,a2,a3,a4,a5)

//! Add two values, result must be in range [0, ITERATE_MAX]
#define GLF_PP_ADD(Lhs, Rhs)                                    _ADD_0(Lhs, Rhs)

//! Subtract two values in range [0, ITERATE_MAX]
#define GLF_PP_SUB(Lhs, Rhs)                                    _SUBTRACT_0(Lhs, Rhs)



//====================================================
// Private
//====================================================

#define _TOKENIZE_2(a1, a2)                                 a1 ## a2
#define _TOKENIZE_3(a1, a2, a3)                             a1 ## a2 ## a3
#define _TOKENIZE_4(a1, a2, a3, a4)                         a1 ## a2 ## a3 ## a4
#define _TOKENIZE_5(a1, a2, a3, a4, a5)                     a1 ## a2 ## a3 ## a4 ## a5
#define _TOKENIZE(...)                                      GLF_EVAL(GLF_TOKENIZE_EVAL(_TOKENIZE_, _NUMARGS(__VA_ARGS__))(__VA_ARGS__))

#define _UNBRACKET_TEST(...)                                1

#define _NUMARGS(...)                                                               \
    GLF_EVAL(_NUMARGS_FUNC(__VA_ARGS__,                                                 \
     10,  9,  8,  7,  6,  5,  4,  3,  2,  1                                         \
    ))                                                                              \

#define _NUMARGS_FUNC(                                                              \
    _00,_01,_02,_03,_04,_05,_06,_07,_08,_09,                                        \
    N,...) N                                                                        \

//! Check if argument has a comma.  Returns 1 if true, 0 if false
#define _HASCOMMA(...)                                                              \
    GLF_EVAL(_NUMARGS_FUNC(__VA_ARGS__,                                                 \
      1,  1,  1,  1,  1,  1,  1,  1,  1,  0,                                        \
    ))                                                                              \

//! Returns 1 if argument list is GLF_EMPTY, 0 otherwise
#define _GLF_IS_EMPTY(...)                                                                                \
        _HASCOMMA(  _TOKENIZE( _IS_EMPTY_CASE_, _HASCOMMA(__VA_ARGS__),                                   \
                                                _HASCOMMA(_IS_EMPTY_BRACKET_TEST __VA_ARGS__),            \
                                                _HASCOMMA(__VA_ARGS__ (GLF_EMPTY)),                       \
                                                _HASCOMMA(_IS_EMPTY_BRACKET_TEST __VA_ARGS__ (GLF_EMPTY)) \
                    )                                                                                     \
        )                                                                                                 \

#define _IS_EMPTY_BRACKET_TEST(...)                          ,
#define _IS_EMPTY_CASE_0001                                  ,
#define _IF_EMPTY_CASE_0(True, False)                        False
#define _IF_EMPTY_CASE_1(True, False)                        True

#define _TUPLE_ELEM_1_0(_0)                                 _0
#define _TUPLE_ELEM_2_0(_0,_1)                              _0
#define _TUPLE_ELEM_2_1(_0,_1)                              _1
#define _TUPLE_ELEM_3_0(_0,_1,_2)                           _0
#define _TUPLE_ELEM_3_1(_0,_1,_2)                           _1
#define _TUPLE_ELEM_3_2(_0,_1,_2)                           _2
#define _TUPLE_ELEM_4_0(_0,_1,_2,_3)                        _0
#define _TUPLE_ELEM_4_1(_0,_1,_2,_3)                        _1
#define _TUPLE_ELEM_4_2(_0,_1,_2,_3)                        _2
#define _TUPLE_ELEM_4_3(_0,_1,_2,_3)                        _3
#define _TUPLE_ELEM_5_0(_0,_1,_2,_3,_4)                     _0
#define _TUPLE_ELEM_5_1(_0,_1,_2,_3,_4)                     _1
#define _TUPLE_ELEM_5_2(_0,_1,_2,_3,_4)                     _2
#define _TUPLE_ELEM_5_3(_0,_1,_2,_3,_4)                     _3
#define _TUPLE_ELEM_5_4(_0,_1,_2,_3,_4)                     _4

#define _ITERATE_0_0
#define _ITERATE_1_1
#define _ITERATE_2_2
#define _ITERATE_3_3
#define _ITERATE_4_4
#define _ITERATE_5_5
#define _ITERATE_6_6
#define _ITERATE_7_7
#define _ITERATE_8_8
#define _ITERATE_9_9
#define _ITERATE_10_10
#define _ITERATE_11_11
#define _ITERATE_12_12
#define _ITERATE_13_13
#define _ITERATE_14_14
#define _ITERATE_15_15
#define _ITERATE_16_16
#define _ITERATE_17_17
#define _ITERATE_18_18
#define _ITERATE_19_19
#define _ITERATE_20_20


#define _ITERATE_FUNC_0(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN)
#define _ITERATE_FUNC_1(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1)
#define _ITERATE_FUNC_2(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2)
#define _ITERATE_FUNC_3(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3)
#define _ITERATE_FUNC_4(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4)
#define _ITERATE_FUNC_5(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4,a5)

#define _ITERATE_0(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 0, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_1(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_0_, Max))
#define _ITERATE_1(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 1, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_2(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_1_, Max))
#define _ITERATE_2(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 2, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_3(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_2_, Max))
#define _ITERATE_3(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 3, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_4(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_3_, Max))
#define _ITERATE_4(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 4, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_5(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_4_, Max))
#define _ITERATE_5(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 5, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_6(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_5_, Max))
#define _ITERATE_6(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 6, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_7(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_6_, Max))
#define _ITERATE_7(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 7, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_8(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_7_, Max))
#define _ITERATE_8(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 8, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_9(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_8_, Max))
#define _ITERATE_9(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 9, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_10(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_9_, Max))
#define _ITERATE_10(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 10, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_11(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_10_, Max))
#define _ITERATE_11(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 11, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_12(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_11_, Max))
#define _ITERATE_12(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 12, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_13(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_12_, Max))
#define _ITERATE_13(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 13, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_14(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_13_, Max))
#define _ITERATE_14(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 14, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_15(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_14_, Max))
#define _ITERATE_15(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 15, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_16(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_15_, Max))
#define _ITERATE_16(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 16, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_17(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_16_, Max))
#define _ITERATE_17(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 17, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_18(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_17_, Max))
#define _ITERATE_18(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 18, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_19(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_18_, Max))
#define _ITERATE_19(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 19, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_20(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_19_, Max))
#define _ITERATE_20(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC_, ac)(Func, 20, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE_21(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_20_, Max))


#define _ITERATE_FUNC__0(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN)
#define _ITERATE_FUNC__1(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1)
#define _ITERATE_FUNC__2(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2)
#define _ITERATE_FUNC__3(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3)
#define _ITERATE_FUNC__4(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4)
#define _ITERATE_FUNC__5(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4,a5)

#define _ITERATE__0(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 0, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__1(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_0_, Max))
#define _ITERATE__1(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 1, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__2(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_1_, Max))
#define _ITERATE__2(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 2, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__3(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_2_, Max))
#define _ITERATE__3(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 3, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__4(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_3_, Max))
#define _ITERATE__4(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 4, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__5(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_4_, Max))
#define _ITERATE__5(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 5, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__6(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_5_, Max))
#define _ITERATE__6(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 6, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__7(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_6_, Max))
#define _ITERATE__7(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 7, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__8(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_7_, Max))
#define _ITERATE__8(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 8, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__9(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_8_, Max))
#define _ITERATE__9(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 9, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__10(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_9_, Max))
#define _ITERATE__10(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 10, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__11(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_10_, Max))
#define _ITERATE__11(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 11, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__12(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_11_, Max))
#define _ITERATE__12(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 12, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__13(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_12_, Max))
#define _ITERATE__13(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 13, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__14(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_13_, Max))
#define _ITERATE__14(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 14, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__15(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_14_, Max))
#define _ITERATE__15(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 15, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__16(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_15_, Max))
#define _ITERATE__16(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 16, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__17(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_16_, Max))
#define _ITERATE__17(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 17, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__18(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_17_, Max))
#define _ITERATE__18(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 18, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__19(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_18_, Max))
#define _ITERATE__19(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 19, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__20(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_19_, Max))
#define _ITERATE__20(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC__, ac)(Func, 20, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE__21(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_20_, Max))


#define _ITERATE_FUNC___0(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN)
#define _ITERATE_FUNC___1(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1)
#define _ITERATE_FUNC___2(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2)
#define _ITERATE_FUNC___3(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3)
#define _ITERATE_FUNC___4(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4)
#define _ITERATE_FUNC___5(Func, IterN, a1,a2,a3,a4,a5 ) Func(IterN,a1,a2,a3,a4,a5)

#define _ITERATE___0(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 0, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___1(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_0_, Max))
#define _ITERATE___1(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 1, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___2(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_1_, Max))
#define _ITERATE___2(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 2, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___3(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_2_, Max))
#define _ITERATE___3(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 3, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___4(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_3_, Max))
#define _ITERATE___4(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 4, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___5(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_4_, Max))
#define _ITERATE___5(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 5, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___6(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_5_, Max))
#define _ITERATE___6(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 6, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___7(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_6_, Max))
#define _ITERATE___7(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 7, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___8(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_7_, Max))
#define _ITERATE___8(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 8, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___9(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_8_, Max))
#define _ITERATE___9(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 9, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___10(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_9_, Max))
#define _ITERATE___10(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 10, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___11(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_10_, Max))
#define _ITERATE___11(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 11, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___12(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_11_, Max))
#define _ITERATE___12(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 12, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___13(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_12_, Max))
#define _ITERATE___13(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 13, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___14(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_13_, Max))
#define _ITERATE___14(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 14, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___15(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_14_, Max))
#define _ITERATE___15(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 15, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___16(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_15_, Max))
#define _ITERATE___16(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 16, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___17(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_16_, Max))
#define _ITERATE___17(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 17, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___18(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_17_, Max))
#define _ITERATE___18(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 18, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___19(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_18_, Max))
#define _ITERATE___19(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 19, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___20(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_19_, Max))
#define _ITERATE___20(Max, Func, ac,a1,a2,a3,a4,a5 ) GLF_TOKENIZE_EVAL(_ITERATE_FUNC___, ac)(Func, 20, a1,a2,a3,a4,a5 ) IFGLF_EMPTY(GLF_EMPTY, _ITERATE___21(Max, Func, ac,a1,a2,a3,a4,a5 ), GLF_TOKENIZE_EVAL(_ITERATE_20_, Max))

#define _INC_0 1
#define _INC_1 2
#define _INC_2 3
#define _INC_3 4
#define _INC_4 5
#define _INC_5 6
#define _INC_6 7
#define _INC_7 8
#define _INC_8 9
#define _INC_9 10
#define _INC_10 11
#define _INC_11 12
#define _INC_12 13
#define _INC_13 14
#define _INC_14 15
#define _INC_15 16
#define _INC_16 17
#define _INC_17 18
#define _INC_18 19
#define _INC_19 20

#define _ADD_0(Lhs, Rhs) GLF_IFEQUAL(Rhs, 0, Lhs, _ADD_1(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_1(Lhs, Rhs) GLF_IFEQUAL(Rhs, 1, Lhs, _ADD_2(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_2(Lhs, Rhs) GLF_IFEQUAL(Rhs, 2, Lhs, _ADD_3(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_3(Lhs, Rhs) GLF_IFEQUAL(Rhs, 3, Lhs, _ADD_4(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_4(Lhs, Rhs) GLF_IFEQUAL(Rhs, 4, Lhs, _ADD_5(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_5(Lhs, Rhs) GLF_IFEQUAL(Rhs, 5, Lhs, _ADD_6(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_6(Lhs, Rhs) GLF_IFEQUAL(Rhs, 6, Lhs, _ADD_7(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_7(Lhs, Rhs) GLF_IFEQUAL(Rhs, 7, Lhs, _ADD_8(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_8(Lhs, Rhs) GLF_IFEQUAL(Rhs, 8, Lhs, _ADD_9(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_9(Lhs, Rhs) GLF_IFEQUAL(Rhs, 9, Lhs, _ADD_10(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_10(Lhs, Rhs) GLF_IFEQUAL(Rhs, 10, Lhs, _ADD_11(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_11(Lhs, Rhs) GLF_IFEQUAL(Rhs, 11, Lhs, _ADD_12(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_12(Lhs, Rhs) GLF_IFEQUAL(Rhs, 12, Lhs, _ADD_13(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_13(Lhs, Rhs) GLF_IFEQUAL(Rhs, 13, Lhs, _ADD_14(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_14(Lhs, Rhs) GLF_IFEQUAL(Rhs, 14, Lhs, _ADD_15(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_15(Lhs, Rhs) GLF_IFEQUAL(Rhs, 15, Lhs, _ADD_16(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_16(Lhs, Rhs) GLF_IFEQUAL(Rhs, 16, Lhs, _ADD_17(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_17(Lhs, Rhs) GLF_IFEQUAL(Rhs, 17, Lhs, _ADD_18(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_18(Lhs, Rhs) GLF_IFEQUAL(Rhs, 18, Lhs, _ADD_19(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_19(Lhs, Rhs) GLF_IFEQUAL(Rhs, 19, Lhs, _ADD_20(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))
#define _ADD_20(Lhs, Rhs) GLF_IFEQUAL(Rhs, 20, Lhs, _ADD_21(GLF_TOKENIZE_EVAL(_INC_,Lhs),Rhs))

#define _DEC_1 0
#define _DEC_2 1
#define _DEC_3 2
#define _DEC_4 3
#define _DEC_5 4
#define _DEC_6 5
#define _DEC_7 6
#define _DEC_8 7
#define _DEC_9 8
#define _DEC_10 9
#define _DEC_11 10
#define _DEC_12 11
#define _DEC_13 12
#define _DEC_14 13
#define _DEC_15 14
#define _DEC_16 15
#define _DEC_17 16
#define _DEC_18 17
#define _DEC_19 18
#define _DEC_20 19

#define _SUBTRACT_0(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 0, _SUBTRACT_1(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_1(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 1, _SUBTRACT_2(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_2(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 2, _SUBTRACT_3(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_3(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 3, _SUBTRACT_4(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_4(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 4, _SUBTRACT_5(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_5(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 5, _SUBTRACT_6(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_6(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 6, _SUBTRACT_7(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_7(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 7, _SUBTRACT_8(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_8(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 8, _SUBTRACT_9(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_9(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 9, _SUBTRACT_10(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_10(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 10, _SUBTRACT_11(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_11(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 11, _SUBTRACT_12(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_12(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 12, _SUBTRACT_13(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_13(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 13, _SUBTRACT_14(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_14(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 14, _SUBTRACT_15(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_15(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 15, _SUBTRACT_16(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_16(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 16, _SUBTRACT_17(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_17(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 17, _SUBTRACT_18(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_18(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 18, _SUBTRACT_19(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_19(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 19, _SUBTRACT_20(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))
#define _SUBTRACT_20(Lhs, Rhs) GLF_IFEQUAL(Lhs, Rhs, 20, _SUBTRACT_21(GLF_TOKENIZE_EVAL(_DEC_,Lhs),Rhs))

#endif
